<template>
  <view class="record-item" @click="gotoPage">
    <img :src="`https://img.qumoyugo.com/webimgbg/pets_cookies_change_${props.item.type}.png`" class="img">
    <view class="right">
      <view class="flex-it u-line-1">
        <view class="title u-line-1">{{props.item.title}}</view>
        <view class="money" :style="{color: fontColorNumber(props.item.amount)}">{{props.item.amount}}</view>
      </view>
      <view class="flex-it">
        <view class="time">{{props.item.createdAt}}</view>
        <view class="explain" :style="{color: fontColorType(props.item.status)}" v-if="props.item.status !== 2">
          {{props.item.statusName}}
        </view>
      </view>
      <view class="tips">
        <view class="explain u-line-2">{{props.item.summary}}</view>
      </view>
    </view>
  </view>
</template>

<script setup>
const props = defineProps({
  item: Object,
  default: () => {}
})
const fontColorNumber = (money) => {
  return Number(money) > 0 ? '#EE751E' : '#333333'
}
const fontColorType = (status) => {
  return status === 0 ? '#E02020' : status === 1 ? '#09BB07' : '#FF7633'
}
const gotoPage = () => {
  if (props.item.type === 1) {
    uni.navigateTo({
      url: `/user/center?id=${props.item.otherCustomerId}`
    })
  }
}
</script>

<style scoped lang="scss">
.record-item{
  display: flex;
  position: relative;
  font-size: 24rpx;
  color: #999999;
  line-height: 36rpx;
  .img{
    width: 52rpx;
    height: 48rpx;
  }
  .right{
    flex: 1;
    padding-left: 32rpx;
    width: calc(100% - 84rpx);
  }
  .title{
    font-size: 28rpx;
    color: #333333;
    font-weight: 400;
    line-height: 30rpx;
    flex: 1;
    padding-right: 24rpx;
    margin-bottom: 12rpx;
    line-height: 28rpx;
    padding-top: 1px;
  }
  .time{
    padding: 6rpx 0;
  }
  .flex-it{
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
  }
  .money{
    font-weight: bold;
    font-size: 30rpx;
  }
  .tips{
    width: calc(100% - 84rpx);
  }
}
</style>
